package org.apache.ibatis.session;

import java.sql.Connection;

/**
 * 创建sqlSession的工厂类接口
 * 可以通过多种方式创建sqlSession
 * @author xieqiaofu
 * Create time: 2019/10/09
 **/
public interface SqlSessionFactory {

    /**
     * 创建默认的SqlSession
     * @return
     */
    SqlSession openSession();

    SqlSession openSession(boolean autoCommit);

    /**
     * 通过传入的connection创建sqlSession
     * @param connection
     * @return
     */
    SqlSession openSession(Connection connection);

    /**
     * 通过传入事务等级创建sqlSession
     * @param level
     * @return
     */
    SqlSession openSession(TransactionIsolationLevel level);

    /**
     * 通过executorType来创建SqlSession
     * @param execType
     * @return
     */
    SqlSession openSession(ExecutorType execType);

    SqlSession openSession(ExecutorType execType, boolean autoCommit);

    SqlSession openSession(ExecutorType execType, TransactionIsolationLevel level);

    /**
     * 通过executorType和connection来创建SqlSession
     * @param execType
     * @param connection
     * @return
     */
    SqlSession openSession(ExecutorType execType, Connection connection);

    /**
     * 获取全局配置，几乎每个核心类都持有全局配置
     * @return
     */
    Configuration getConfiguration();
}
